package com.google.android.vending.expansion.downloader.impl;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.os.Messenger;
import com.android.vending.expansion.downloader.R.string;
import com.google.android.vending.expansion.downloader.DownloadProgressInfo;
import com.google.android.vending.expansion.downloader.DownloaderClientMarshaller;
import com.google.android.vending.expansion.downloader.Helpers;
import com.google.android.vending.expansion.downloader.IDownloaderClient;

public class DownloadNotification
  implements IDownloaderClient
{
  static final String LOGTAG = "DownloadNotification";
  static final int NOTIFICATION_ID = "DownloadNotification".hashCode();
  private IDownloaderClient mClientProxy;
  private PendingIntent mContentIntent;
  private final Context mContext;
  private Notification mCurrentNotification;
  private String mCurrentText;
  private String mCurrentTitle;
  final ICustomNotification mCustomNotification;
  private CharSequence mLabel;
  private Notification mNotification;
  private final NotificationManager mNotificationManager;
  private DownloadProgressInfo mProgressInfo;
  private int mState = -1;

  DownloadNotification(Context paramContext, CharSequence paramCharSequence)
  {
    this.mContext = paramContext;
    this.mLabel = paramCharSequence;
    this.mNotificationManager = ((NotificationManager)this.mContext.getSystemService("notification"));
    this.mCustomNotification = CustomNotificationFactory.createCustomNotification();
    this.mNotification = new Notification();
    this.mCurrentNotification = this.mNotification;
  }

  public PendingIntent getClientIntent()
  {
    return this.mContentIntent;
  }

  public void onDownloadProgress(DownloadProgressInfo paramDownloadProgressInfo)
  {
    this.mProgressInfo = paramDownloadProgressInfo;
    if (this.mClientProxy != null)
      this.mClientProxy.onDownloadProgress(paramDownloadProgressInfo);
    if (paramDownloadProgressInfo.mOverallTotal <= 0L)
    {
      this.mNotification.tickerText = this.mCurrentTitle;
      this.mNotification.icon = 17301633;
      this.mNotification.setLatestEventInfo(this.mContext, this.mLabel, this.mCurrentText, this.mContentIntent);
    }
    for (this.mCurrentNotification = this.mNotification; ; this.mCurrentNotification = this.mCustomNotification.updateNotification(this.mContext))
    {
      this.mNotificationManager.notify(NOTIFICATION_ID, this.mCurrentNotification);
      return;
      this.mCustomNotification.setCurrentBytes(paramDownloadProgressInfo.mOverallProgress);
      this.mCustomNotification.setTotalBytes(paramDownloadProgressInfo.mOverallTotal);
      this.mCustomNotification.setIcon(17301633);
      this.mCustomNotification.setPendingIntent(this.mContentIntent);
      this.mCustomNotification.setTicker(this.mLabel + ": " + this.mCurrentText);
      this.mCustomNotification.setTitle(this.mLabel);
      this.mCustomNotification.setTimeRemaining(paramDownloadProgressInfo.mTimeRemaining);
    }
  }

  public void onDownloadStateChanged(int paramInt)
  {
    if (this.mClientProxy != null)
      this.mClientProxy.onDownloadStateChanged(paramInt);
    if (paramInt != this.mState)
    {
      this.mState = paramInt;
      if ((paramInt != 1) && (this.mContentIntent != null));
    }
    else
    {
      return;
    }
    int i;
    int j;
    int k;
    Notification localNotification3;
    switch (paramInt)
    {
    case 1:
    case 6:
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    default:
      i = 17301642;
      j = Helpers.getDownloaderStringResourceIDFromState(paramInt);
      k = 1;
      this.mCurrentText = this.mContext.getString(j);
      this.mCurrentTitle = this.mLabel.toString();
      this.mCurrentNotification.tickerText = (this.mLabel + ": " + this.mCurrentText);
      this.mCurrentNotification.icon = i;
      this.mCurrentNotification.setLatestEventInfo(this.mContext, this.mCurrentTitle, this.mCurrentText, this.mContentIntent);
      if (k != 0)
        localNotification3 = this.mCurrentNotification;
      break;
    case 0:
    case 4:
    case 2:
    case 3:
    case 5:
    case 7:
    case 15:
    case 16:
    case 17:
    case 18:
    case 19:
    }
    Notification localNotification2;
    for (localNotification3.flags = (0x2 | localNotification3.flags); ; localNotification2.flags = (0x10 | localNotification2.flags))
    {
      this.mNotificationManager.notify(NOTIFICATION_ID, this.mCurrentNotification);
      return;
      i = 17301642;
      j = R.string.state_unknown;
      k = 0;
      break;
      i = 17301633;
      j = Helpers.getDownloaderStringResourceIDFromState(paramInt);
      k = 1;
      break;
      i = 17301634;
      j = Helpers.getDownloaderStringResourceIDFromState(paramInt);
      k = 1;
      break;
      i = 17301634;
      j = Helpers.getDownloaderStringResourceIDFromState(paramInt);
      k = 0;
      break;
      i = 17301642;
      j = Helpers.getDownloaderStringResourceIDFromState(paramInt);
      k = 0;
      break;
      Notification localNotification1 = this.mCurrentNotification;
      localNotification1.flags = (0xFFFFFFFD & localNotification1.flags);
      localNotification2 = this.mCurrentNotification;
    }
  }

  public void onServiceConnected(Messenger paramMessenger)
  {
  }

  public void resendState()
  {
    if (this.mClientProxy != null)
      this.mClientProxy.onDownloadStateChanged(this.mState);
  }

  public void setClientIntent(PendingIntent paramPendingIntent)
  {
    this.mContentIntent = paramPendingIntent;
  }

  public void setMessenger(Messenger paramMessenger)
  {
    this.mClientProxy = DownloaderClientMarshaller.CreateProxy(paramMessenger);
    if (this.mProgressInfo != null)
      this.mClientProxy.onDownloadProgress(this.mProgressInfo);
    if (this.mState != -1)
      this.mClientProxy.onDownloadStateChanged(this.mState);
  }

  public static abstract interface ICustomNotification
  {
    public abstract void setCurrentBytes(long paramLong);

    public abstract void setIcon(int paramInt);

    public abstract void setPendingIntent(PendingIntent paramPendingIntent);

    public abstract void setTicker(CharSequence paramCharSequence);

    public abstract void setTimeRemaining(long paramLong);

    public abstract void setTitle(CharSequence paramCharSequence);

    public abstract void setTotalBytes(long paramLong);

    public abstract Notification updateNotification(Context paramContext);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.google.android.vending.expansion.downloader.impl.DownloadNotification
 * JD-Core Version:    0.6.2
 */